<?php   
class ControllerHome extends Controller {  
	function index() {
		$response =& $this->locator->get('response');
		$database =& $this->locator->get('database');
		$url      =& $this->locator->get('url');
		$language =& $this->locator->get('language');
		$template =& $this->locator->get('template');
		$module   =& $this->locator->get('module');
		$user   =& $this->locator->get('user');
	  
    	if (!$user->isLogged())
    	$response->redirect($url->ssl('login'));
    	
    	$language->load('controller/home.php');
	
		$template->set('title', $language->get('heading_title'));
		
    	$view = $this->locator->create('template');

    	$view->set('heading_title', $language->get('heading_title'));
    	$view->set('heading_description', $language->get('heading_description'));

		$view->set('hoy', date('d/m/Y', time()));
		
	      	$view->set('text_logout', 'Cerrar Sesi&oacute;n');

			$persona = $user->getPERSONA();
			$view->set('logout', $url->ssl('logout'));
			
			$permisos = $database->getRows("select distinct f.formulario from perfiles f inner join grupos g on f.grupo = g.grupo inner join usuariosgrupos p on g.grupo = p.grupo where p.usuario = '" . $persona . "'");
			foreach ($permisos as $permiso)
			{
				$view->set($permiso['formulario'], $url->ssl($permiso['formulario']));
				
			}

		
		$template->set('content', $view->fetch('content/home.tpl')); 
	
		$template->set($module->fetch());
	
		$response->set($template->fetch('layout.tpl'));  
  	}
	
}
?>